/**
 * input框输入内容时去除空格
 * @param event
 * @returns
 */
const getValueFromEvent = (event: any) => {
  console.log('event.target.value', event.target.value)
  return event.target.value.replace(/(^\s*)|(\s*$)/g, '')
}

/**
 * 验证手机号码
 * @param {string} mobile
 * @returns {boolean}
 */
const validateMobile = (mobile: string) => {
  const re =
    /^(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])\d{8}$/
  return re.test(mobile)
}

/**
 * 验证邮箱
 * @param {string} email
 * @returns {boolean}
 */
const validateEmail = (email: string) => {
  const re =
    /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/
  return re.test(email)
}
/**
 * 获取文字长度
 * @param value
 * @returns
 */
const getTextLength = (value: string) => {
  return value.replace(/[^\u0000-\u00ff]/g, 'aa').length
}
export {
  getValueFromEvent,
  validateMobile,
  validateEmail,
  getTextLength
}
